package net.lab1024.sa.admin.module.business.quotation.controller;

import net.lab1024.sa.admin.module.business.quotation.domain.form.QuotationAddForm;
import net.lab1024.sa.admin.module.business.quotation.domain.form.QuotationItemsQueryForm;
import net.lab1024.sa.admin.module.business.quotation.domain.form.QuotationQueryForm;
import net.lab1024.sa.admin.module.business.quotation.domain.form.QuotationUpdateForm;
import net.lab1024.sa.admin.module.business.quotation.domain.vo.QuotationDetailVo;
import net.lab1024.sa.admin.module.business.quotation.domain.vo.QuotationItemsVO;
import net.lab1024.sa.admin.module.business.quotation.domain.vo.QuotationVO;
import net.lab1024.sa.admin.module.business.quotation.service.QuotationService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

/**
 * 报价信息 Controller
 *
 * @Author zzx
 * @Date 2025-08-07 19:37:04
 * @Copyright zzx
 */

@RestController
@Tag(name = "报价信息")
public class QuotationController {

    @Resource
    private QuotationService quotationService;

    @Operation(summary = "获取报价单详情-只有报价信息 @author zzx")
    @GetMapping("/quotation/querySortDetail/{quotationId}")
    @SaCheckPermission("quotation:querySortDetail")
    public ResponseDTO<QuotationDetailVo> querySortDetail(@PathVariable Long quotationId) {
        return ResponseDTO.ok(quotationService.querySortDetail(quotationId));
    }
    @Operation(summary = "获取报价单详情-包含报价明细 @author zzx")
    @GetMapping("/quotation/queryDetail/{quotationId}")
    @SaCheckPermission("quotation:queryDetail")
    public ResponseDTO<QuotationDetailVo> queryDetail(@PathVariable Long quotationId) {
        return ResponseDTO.ok(quotationService.queryDetail(quotationId));
    }

    @Operation(summary = "分页查询 @author zzx")
    @PostMapping("/quotation/queryPage")
    @SaCheckPermission("quotation:query")
    public ResponseDTO<PageResult<QuotationVO>> queryPage(@RequestBody @Valid QuotationQueryForm queryForm) {
        return ResponseDTO.ok(quotationService.queryPage(queryForm));
    }

    @Operation(summary = "分页查询 @author zzx")
    @PostMapping("/quotation/queryItemsPage")
    @SaCheckPermission("quotation:queryItemsPage")
    public ResponseDTO<PageResult<QuotationItemsVO>> queryItemsPage(@RequestBody @Valid QuotationItemsQueryForm queryForm) {
        return ResponseDTO.ok(quotationService.queryItemsPage(queryForm));
    }

    @Operation(summary = "添加 @author zzx")
    @PostMapping("/quotation/addOrUpdate")
    @SaCheckPermission("quotation:addOrUpdate")
    public ResponseDTO<String> addOrUpdate(@RequestBody @Valid QuotationUpdateForm form) {
        return quotationService.addOrUpdate(form);
    }

    @Operation(summary = "更新 @author zzx")
    @PostMapping("/quotation/update")
    @SaCheckPermission("quotation:update")
    public ResponseDTO<String> update(@RequestBody @Valid QuotationUpdateForm updateForm) {
        return quotationService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author zzx")
    @PostMapping("/quotation/batchDelete")
    @SaCheckPermission("quotation:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return quotationService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author zzx")
    @GetMapping("/quotation/delete/{quotationId}")
    @SaCheckPermission("quotation:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long quotationId) {
        return quotationService.delete(quotationId);
    }

}
